package com.hexinfo.dmpro.admin.model.req;

import com.hexinfo.dmpro.common.base.BaseRequest;
import com.hexinfo.dmpro.admin.model.vo.UserVo;
import lombok.Data;

import java.util.List;

/**
 * @ClassName UserRequest
 * @Describe
 * @Author ml.wang
 * @Date 2021-06-18
 */
@Data
public class UserRequest extends BaseRequest {

    private Boolean enabled;

    public static UserRequest viewToRequest(UserVo view) {
        UserRequest request = new UserRequest();
        request.setId(view.getId());
        request.setBlurry(view.getBlurry());
        request.setEnabled(view.getEnabled());
        List<String> createTime = view.getCreateTime();
        if (createTime != null) {
            if (createTime.size() >= 1) {
                request.setCreateTimeStart(createTime.get(0));
            }
            if (createTime.size() == 2) {
                request.setCreateTimeEnd(createTime.get(1));
            }
        }
        request.setCreateBy(view.getCreateBy());
        List<String> lastUpdateTime = view.getLastUpdateTime();
        if (lastUpdateTime != null) {
            if (lastUpdateTime.size() >= 1) {
                request.setLastUpdateTimeStart(lastUpdateTime.get(0));
            }
            if (lastUpdateTime.size() == 2) {
                request.setLastUpdateTimeEnd(lastUpdateTime.get(1));
            }
        }
        request.setLastUpdateBy(view.getLastUpdateBy());
        return request;
    }

}
